<template>
  <div class="pad-out-box">
    <el-table :border="true" :data="tableData">
      <el-table-column align="center" label="序号">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="描述" prop="description"></el-table-column>
      <el-table-column align="center" label="更新时间">
        <template slot-scope="scope">
          <span>{{ scope.row.updateTime | formatDateTime('YYYY-MM-DD HH:mm') }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="类型">
        <template slot-scope="scope">
          <span v-if="scope.row.type == 'meeting'">会议</span>
          <span v-if="scope.row.type == 'work'">事件</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="goInfo(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Pagination @change="pageChange" :total="total" paginationLayout="total, prev, pager, next"/>
  </div>
</template>
<script>
import { apiDraft } from '../../api/workTrace';

export default {
  data() {
    return {
      tableData: [],
      total: 0,
      currentPage: 1,
      pageSize: 10,
      userInfo: JSON.parse(localStorage.getItem('userInfo'))
    };
  },

  mounted() {
    this.getDataSource();
  },

  methods: {
    async getDataSource(more) {
      let res = await apiDraft({
        currentPage: more ? this.currentPage : 1,
        pageSize: this.pageSize,
        createUser: this.userInfo.key,
      });
      this.tableData = res.rows || [];
      this.total = res.total || 0;
    },

    //详情
    goInfo(row){
      let params = {
        name: 'trace-summary-info',
        query: {
          spaceKey:this.$route.query.spaceKey,
          meetingKey:row.primaryKey
        },
      };

      let router = this.$router.resolve(params);
      window.open(router.href, '_blank');
    },

    //分页
    pageChange(page) {
      this.currentPage = page.currentPage
      this.getDataSource('more');
    },
  },
};
</script>
<style lang="scss" scoped></style>
